#!/bin/bash
# using dialog to create a menu
#chinese China Termux Ubuntu
red='\033[1;31m'
#红色
green='\033[1;32m'
#绿色
yellow='\033[1;33m'
#黄色
blue='\033[1;34m'
#蓝色
light_cyan='\033[1;96m'
#淡青色
reset='\033[0m'
#重置颜色
check_server1() {
wauo=$(whiptail --ok-button "下载" --title "下载服务器客户端" --menu "请选择服务器的版本" 0 50 50 \
"58" "1.19.40.02" \
"57" "1.19.31" \
"56" "1.19.30" \
"55" "1.19.21" \
"54" "1.19.20.02" \
"53" "1.19.11.01" \
"52" "1.19.10.03" \
"51" "1.19.2.02" \
"50" "1.19.1.01" \
"49" "1.18.32.02" \
"48" "1.18.31.04" \
"47" "1.18.30.04" \
"46" "1.18.12.01" \
"45" "1.18.11.01" \
"44" "1.18.2.03" \
"43" "1.18.1.02" \
"42" "1.18.0.02" \
"41" "1.17.41.01" \
"40" "1.17.40.06" \
"39" "1.17.34.02" \
"38" "1.17.32.02" \
"37" "1.17.11.01" \
"36" "1.17.10.04" \
"35" "1.17.1.01" \
"34" "1.17.0.03" \
"33" "1.16.221.01" \
"32" "1.16.220.02" \
"31" "1.16.210.05" \
"30" "1.16.201.02" \
"29" "1.16.200.02" \
"28" "1.16.101.01" \
"27" "1.16.100.04" \
"26" "1.16.40.02" \
"25" "1.16.20.03" \
"24" "1.16.10.02" \
"23" "1.16.1.02" \
"22" "1.16.0.2" \
"21" "1.14.60.5" \
"20" "1.14.32.1" \
"19" "1.14.30.2" \
"18" "1.14.20.1" \
"17" "1.14.1.4" \
"16" "1.14.0.9" \
"15" "1.13.3.0" \
"14" "1.13.2.0" \
"13" "1.13.1.5" \
"12" "1.13.0.34" \
"11" "1.12.1.1" \
"10" "1.12.0.28" \
"9" "1.11.4.2" \
"8" "1.11.2.1" \
"7" "1.11.1.2" \
"6" "1.11.0.23" \
"5" "1.10.0.7" \
"4" "1.9.0.15" \
"3" "1.8.1.2" \
"2" "1.8.0.24" \
"1" "1.7.0.13" \
3>&1 1>&2 2>&3)
case ${wauo} in
58)JTK="1.19.40.02";;
57)JTK="1.19.31";;
56)JTK="1.19.30";;
55)JTK="1.19.21";;
54)JTK="1.19.20.02";;
53)JTK="1.19.11.01";;
52)JTK="1.19.10.03";;
51)JTK="1.19.2.02";;
50)JTK="1.19.1.01";;
49)JTK="1.18.32.02";;
48)JTK="1.18.31.04";;
47)JTK="1.18.30.04";;
46)JTK="1.18.12.01";;
45)JTK="1.18.11.01";;
44)JTK="1.18.2.03";;
43)JTK="1.18.1.02";;
42)JTK="1.18.0.02";;
41)JTK="1.17.41.01";;
40)JTK="1.17.40.06";;
39)JTK="1.17.34.02";;
38)JTK="1.17.32.02";;
37)JTK="1.17.11.01";;
36)JTK="1.17.10.04";;
35)JTK="1.17.1.01";;
34)JTK="1.17.0.03";;
33)JTK="1.16.221.01";;
32)JTK="1.16.220.02";;
31)JTK="1.16.210.05";;
30)JTK="1.16.201.02";;
29)JTK="1.16.200.02";;
28)JTK="1.16.101.01";;
27)JTK="1.16.100.04";;
26)JTK="1.16.40.02";;
25)JTK="1.16.20.03";;
24)JTK="1.16.10.02";;
23)JTK="1.16.1.02";;
22)JTK="1.16.0.2";;
21)JTK="1.14.60.5";;
20)JTK="1.14.32.1";;
19)JTK="1.14.30.2";;
18)JTK="1.14.20.1";;
17)JTK="1.14.1.4";;
16)JTK="1.14.0.9";;
15)JTK="1.13.3.0";;
14)JTK="1.13.2.0";;
13)JTK="1.13.1.5";;
12)JTK="1.13.0.34";;
11)JTK="1.12.1.1";;
10)JTK="1.12.0.28";;
9)JTK="1.11.4.2";;
8)JTK="1.11.2.1";;
7)JTK="1.11.1.2";;
6)JTK="1.11.0.23";;
5)JTK="1.10.0.7";;
4)JTK="1.9.0.15";;
3)JTK="1.8.1.2";;
2)JTK="1.8.0.24";;
1)JTK="1.7.0.13";;
esac
cd
mkdir server
cd server
echo -e "${green}[]正在下载服务器客户端,${yellow}请您保持网络通畅${reset}"
wget https://minecraft.azureedge.net/bin-linux/bedrock-server-${JTK}.zip
echo -e "${green}[]开始解压文件${reset}"
unzip bedrock-server-${JTK}.zip
rm -frv bedrock-server-${JTK}.zip
chmod +x bedrock_server
chmod +555 bedrock_server
cat > server.properties << EOF
EOF
cat > server.properties << EOF
server-name=我的mc服务器
gamemode=survival
difficulty=easy
allow-cheats=false
max-players=10
online-mode=true
white-list=false
server-port=19132
server-portv6=19133
view-distance=32
tick-distance=4
player-idle-timeout=30
max-threads=8
level-name=Bedrock level
level-seed=
default-player-permission-level=member
texturepack-required=false
content-log-file-enabled=false
compression-threshold=1
server-authoritative-movement=server-auth
player-movement-score-threshold=20
player-movement-distance-threshold=0.3
player-movement-duration-threshold-in-ms=500
correct-player-movement=false
server-authoritative-block-breaking=false
EOF
}
check_server() {
if [ -e server/bedrock_server ]
   then
   JTK1
   else
   JTK3
   check_server1
fi
}
function JTK1() {
   cd
   if [ -e server/bedrock_server ]
   then
   echo -e "${green}[]已检测到服务器文件，${light_cyan}是否配置服务器？(y/n)${reset}"
   read -p "" -t 30 cho
   case $cho in
   "y")
      bash -c "$(curl https://gitee.com/sansjtw/minecraft_rope/raw/master/Minecraft_rope)"
      ;;
   "n")
       check_server1
       bash -c "$(curl https://gitee.com/sansjtw/minecraft_rope/raw/master/Minecraft_rope)"
       ;;
    *)
      bash -c "$(curl https://gitee.com/sansjtw/minecraft_rope/raw/master/Minecraft_rope)"
     ;;
   esac
   fi
}
function JTK3() {
   echo -e "${yellow}[!]是否安装依赖？(y/n)${reset}"
   read -p "" -t 30 choo
   case $choo in
   "y")
      sudo sed -i "s@http://.*archive.ubuntu.com@https://mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list
      sudo sed -i "s@http://.*security.ubuntu.com@https://mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list
      sudo apt-get update
      apt install dialog
      apt install whiptail
      sudo apt install git libglib2.0-dev libfdt-dev libpixman-1-dev zlib1g-dev libsdl1.2-dev libsnappy-dev liblzo2-dev automake gcc python3 python3-setuptools build-essential ninja-build libspice-server-dev libsdl2-dev libspice-protocol-dev meson libgtk-3-dev libaio-dev gettext samba xz-utils usbutils telnet wget libvirglrenderer-dev libusb-dev libusb-1.0-0 pulseaudio -y
   echo -e "${yellow}[*]回车安装fortune软件包${reset}"
   read -r -p "" input
   pkg install fortune
   fortune
   ;;
   "n")
      ;;
esac
}
cd
check_server